-
Notifications
You must be signed in to change notification settings - Fork 26
Feat: native SPL support #738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughAdds ATA/eATA support and remapping across the codebase: new token_programs module in magicblock-core (ATA/eATA PDA derivation, ATA inspection, EphemeralAta and conversion helpers); workspace additions for spl-token and spl-token-2022; chainlink fetch/cloner changes to detect, subscribe to, and clone ATAs and derive/handle eATAs (including delegated paths); remapping of delegated SPL ATAs to eATAs in scheduling/commit paths (programs/magicblock); test helpers and integration tests for ATA↔eATA replacement; and package/manifest metadata updates. No public API signatures were changed. Possibly related PRs
Suggested reviewers
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (5)📓 Common learnings📚 Learning: 2025-11-24T14:21:00.996ZApplied to files:
📚 Learning: 2025-12-03T09:36:01.527ZApplied to files:
📚 Learning: 2025-10-26T16:54:39.084ZApplied to files:
📚 Learning: 2025-11-24T08:45:11.164ZApplied to files:
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Manual Deploy AvailableYou can trigger a manual deploy of this PR branch to testnet: Alternative: Comment
Comment updated automatically when the PR is synchronized. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (11)
.github/packages/npm-package/package.json(1 hunks).github/packages/npm-package/package.json.tmpl(1 hunks)magicblock-chainlink/Cargo.toml(2 hunks)magicblock-chainlink/src/chainlink/fetch_cloner.rs(10 hunks)magicblock-chainlink/src/testing/eatas.rs(1 hunks)magicblock-chainlink/src/testing/mod.rs(1 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit.rs(2 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs(2 hunks)test-integration/Cargo.toml(1 hunks)test-integration/test-chainlink/Cargo.toml(1 hunks)test-integration/test-chainlink/tests/ix_ata_eata_replace.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (17)
📓 Common learnings
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Applied to files:
test-integration/Cargo.tomltest-integration/test-chainlink/Cargo.toml.github/packages/npm-package/package.json.tmpl.github/packages/npm-package/package.jsonmagicblock-chainlink/Cargo.toml
📚 Learning: 2025-11-07T18:19:48.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: test-integration/programs/schedulecommit/Cargo.toml:19-20
Timestamp: 2025-11-07T18:19:48.996Z
Learning: In Solana programs (crates depending on solana-program), the empty feature flags `custom-heap = []` and `custom-panic = []` are standard declarations required to avoid compiler warnings. These should not be flagged as unused features in Cargo.toml files for Solana program crates.
Applied to files:
test-integration/test-chainlink/Cargo.tomlmagicblock-chainlink/Cargo.toml
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.
Applied to files:
.github/packages/npm-package/package.json.tmpl.github/packages/npm-package/package.json
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.
Applied to files:
.github/packages/npm-package/package.json.tmpl.github/packages/npm-package/package.json
📚 Learning: 2025-10-27T09:55:17.808Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: magicblock-chainlink/src/remote_account_provider/mod.rs:296-298
Timestamp: 2025-10-27T09:55:17.808Z
Learning: In the magicblock-validator codebase, it is acceptable to log API keys in debug/info statements because logs are private and the team considers API keys not that sensitive in their security model.
Applied to files:
.github/packages/npm-package/package.json.tmpl
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rstest-integration/test-chainlink/tests/ix_ata_eata_replace.rsmagicblock-chainlink/src/testing/eatas.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-11-25T11:07:20.001Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/programs/flexi-counter/src/processor.rs:643-680
Timestamp: 2025-11-25T11:07:20.001Z
Learning: In the compressed delegation architecture, ownership reassignment during undelegation is handled by the delegation program itself, not by the owner program's external undelegate handler. The external undelegate handler (e.g., `process_external_undelegate_compressed` in flexi-counter) is a callback for program-specific cleanup (restoring lamports and data) after the delegation program has already reassigned ownership back to the original owner stored in the CompressedDelegationRecord.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
test-integration/test-chainlink/tests/ix_ata_eata_replace.rsmagicblock-chainlink/src/testing/mod.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
test-integration/test-chainlink/tests/ix_ata_eata_replace.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
test-integration/test-chainlink/tests/ix_ata_eata_replace.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.
Applied to files:
test-integration/test-chainlink/tests/ix_ata_eata_replace.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-19T11:31:24.218Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-chainlink/tests/ix_01_ensure-accounts.rs:85-114
Timestamp: 2025-11-19T11:31:24.218Z
Learning: In the magicblock-validator codebase, compressed delegation records are never subscribed to by design. Tests for compressed delegation flows should focus on verifying that the delegated account (e.g., counter PDA) is cloned as delegated and not subscribed, but do not need to check for subscription to delegation-record-like PDAs in the compressed path because subscriptions to compressed delegation records never occur.
Applied to files:
test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rs
🧬 Code graph analysis (2)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (4)
magicblock-chainlink/src/remote_account_provider/remote_account.rs (3)
owner(54-60)owner(260-262)data(71-77)magicblock-magic-program-api/src/args.rs (1)
data(26-28)programs/magicblock/src/mutate_accounts/account_mod_data.rs (1)
data(137-144)magicblock-committor-service/src/tasks/task_builder.rs (1)
committed_accounts(142-145)
test-integration/test-chainlink/tests/ix_ata_eata_replace.rs (2)
magicblock-chainlink/src/testing/eatas.rs (4)
create_ata_account(34-57)create_eata_account(59-79)derive_ata(18-24)derive_eata(26-32)magicblock-chainlink/src/remote_account_provider/remote_account.rs (1)
delegated(95-101)
🔇 Additional comments (20)
test-integration/test-chainlink/Cargo.toml (1)
25-25: LGTM!The workspace dependency addition for
spl-tokenaligns with the broader ATA/eATA test support introduced in this PR..github/packages/npm-package/package.json.tmpl (1)
7-10: LGTM!Repository and bugs URLs correctly updated to reflect the rename from
ephemeral-validatortomagicblock-validator.magicblock-chainlink/Cargo.toml (1)
24-35: LGTM!The new dependencies (
solana-program,spl-token,spl-token-2022) appropriately enable the ATA/eATA support functionality introduced in this PR. Using workspace versions ensures consistency across the codebase..github/packages/npm-package/package.json (1)
5-11: LGTM!All metadata URLs consistently updated to reference
magicblock-validatorrepository.magicblock-chainlink/src/testing/mod.rs (1)
9-12: LGTM!The new
eatasmodule is properly gated with#[cfg(any(test, feature = "dev-context"))], consistent with other testing modules in this file.programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
39-64: LGTM!The program ID constants and PDA derivation functions are correctly defined. The
derive_atauses the standard ATA seeds ([owner, SPL_TOKEN_PROGRAM_ID, mint]withASSOCIATED_TOKEN_PROGRAM_ID), andderive_eatauses the eATA program's seeds ([owner, mint]withEATA_PROGRAM_ID).
244-248: LGTM!The
target_pubkey(potentially remapped to eATA) is correctly used when constructing theCommittedAccount, ensuring that commits/undelegates target the appropriate address.test-integration/Cargo.toml (1)
92-92: Version compatibility confirmed; no action required.The exact version pin
spl-token = "=7.0"is compatible withsolana-sdk 2.2and aligns with the Solana 2.x ecosystem. This pinning strategy ensures reproducible builds across the workspace.test-integration/test-chainlink/tests/ix_ata_eata_replace.rs (4)
1-12: LGTM!Imports are appropriate for the test scenarios. The use of
ReadableAccountandPacktraits are correctly imported for SPL token account handling.
15-72: LGTM!Test correctly verifies that when an eATA is delegated to the validator, the cloned ATA account is populated with the eATA's data. The assertions cover all relevant token account fields including mint, amount, owner, close_authority, state, delegated_amount, is_native, and the delegated flag.
74-108: LGTM!Good negative test case. Correctly verifies that without a delegation record, the cloned ATA retains its original data and is not marked as delegated.
110-161: LGTM!Good edge case test. Correctly verifies that when the eATA is delegated to a different validator (not ours), the cloned ATA retains its original data and is not marked as delegated.
magicblock-chainlink/src/testing/eatas.rs (4)
18-24: LGTM!The ATA derivation uses the correct seeds
[owner, SPL_TOKEN_PROGRAM_ID, mint]per the SPL Associated Token Program specification.
26-32: LGTM!The eATA derivation correctly uses seeds
[owner, mint]with the EATA program ID, matching the derivation infetch_cloner.rs.
34-57: LGTM!The function correctly creates a mock SPL Token account with proper initialization using
SplAccount::packand calculates minimum rent-exempt lamports.
59-79: LGTM!The eATA account creation correctly matches the expected data layout (owner 32B + mint 32B + amount 8B) that
fetch_cloner.rs::maybe_into_ataparses. The conditional owner selection based ondelegateflag correctly distinguishes delegated vs. non-delegated eATAs.magicblock-chainlink/src/chainlink/fetch_cloner.rs (4)
16-20: LGTM!New imports for SPL token handling are appropriate:
Account,COption,Pack,Rent, andSplAccount/AccountStatefor constructing token accounts.
669-763: LGTM!The account categorization logic cleanly integrates ATA detection. ATAs are properly separated into their own category for special handling downstream, following the existing pattern for delegated accounts and programs.
3331-3394: LGTM!The
is_atafunction correctly:
- Validates account ownership (SPL Token or Token-2022)
- Checks minimum data length before parsing
- Extracts mint and owner from the standard SPL token account layout
- Verifies the account pubkey matches the derived ATA address
This ensures only valid ATAs are detected.
3396-3409: LGTM!The eATA derivation correctly uses
try_find_program_addresswith seeds[owner, mint]and returnsOptionto safely handle potential derivation failures.
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
Outdated
Show resolved
Hide resolved
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
Show resolved
Hide resolved
taco-paco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs similiar implementation for ScheduleBaseIntent case as it also contains committed accounts.
Also an interesting discussion:
Shall we implement such mappings on smart contract level or in "prepocessing" in ScheduledCommitsProcessorImpl?
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
Show resolved
Hide resolved
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (7)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
196-205: Replace unreachable fallback with.expect()for clarity.The
try_into()calls on lines 197-204 cannot fail becausedata.len() >= 64(line 194) guarantees the slices are exactly 32 bytes. The fallback to[0u8; 32]is dead code and obscures this invariant.Apply this diff:
- let mint = - Pubkey::new_from_array(match data[0..32].try_into() { - Ok(a) => a, - Err(_) => [0u8; 32], - }); - let wallet_owner = - Pubkey::new_from_array(match data[32..64].try_into() { - Ok(a) => a, - Err(_) => [0u8; 32], - }); + let mint = Pubkey::new_from_array( + data[0..32].try_into().expect("slice is 32 bytes") + ); + let wallet_owner = Pubkey::new_from_array( + data[32..64].try_into().expect("slice is 32 bytes") + );programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (1)
268-282: Clarify or fix the 72-byte allocation.The helper allocates 72 bytes but the comment states only the first 64 bytes (32 for mint + 32 for owner) are needed. Either reduce to
vec![0u8; 64]or explain why the extra 8 bytes are necessary.Apply this diff if the extra bytes are not needed:
- let mut data = vec![0u8; 72]; + let mut data = vec![0u8; 64];magicblock-chainlink/src/testing/eatas.rs (1)
57-66: Consider consolidating EphemeralAta definition.This struct appears to be duplicated in
fetch_cloner.rs(lines 3414-3421). Consider moving it to a shared location to maintain a single source of truth.magicblock-chainlink/src/chainlink/fetch_cloner.rs (4)
1107-1194: Critical: eATA subscriptions are never cleaned up.At line 1122, the code subscribes to the derived eATA pubkey, but this subscription is never added to
delegated_acc_subsor any other cleanup structure. When the ATA handling fails or the eATA is not delegated to this validator, these subscriptions remain active indefinitely, causing a subscription leak.Track eATA subscriptions and cancel them when appropriate:
if !atas.is_empty() { let mut ata_join_set = JoinSet::new(); + let mut eata_subs = Vec::new(); // Subscribe first so subsequent fetches are kept up-to-date for (ata_pubkey, _, ata_info, slot_for_ata) in &atas { let _ = self.subscribe_to_account(ata_pubkey).await; if let Some((eata, _)) = try_derive_eata_address_and_bump( &ata_info.owner, &ata_info.mint, ) { let _ = self.subscribe_to_account(&eata).await; + eata_subs.push(eata); // ... existing spawn logic ... } } let ata_results = ata_join_set.join_all().await; + let mut eatas_to_cancel = HashSet::new(); + for res in ata_results.into_iter() { match res { Ok(Ok(AccountWithCompanion { pubkey: ata_pubkey, account: ata_account, companion_pubkey: eata_pubkey, companion_account: maybe_eata_account, })) => { // ... existing conversion logic ... + + // If we didn't convert the eATA, cancel its subscription + if maybe_eata_account.is_none() || !account_to_clone.delegated() { + eatas_to_cancel.insert(eata_pubkey); + } } Ok(Err(err)) => { warn!("Failed to resolve ATA/eATA companion: {err}"); + // Cancel eATA subscription on error } Err(join_err) => { warn!("Failed to join ATA/eATA fetch task: {join_err}"); } } } + + // Cancel eATA subscriptions that weren't used + if !eatas_to_cancel.is_empty() { + cancel_subs( + &self.remote_account_provider, + CancelStrategy::All(eatas_to_cancel), + ) + .await; + } }
3423-3451: UseFrominstead ofIntofor better ergonomics.Implementing
From<EphemeralAta> for AccountSharedDatais preferred overIntoand will automatically provide theIntotrait via blanket implementation.-impl Into<AccountSharedData> for EphemeralAta { - fn into(self) -> AccountSharedData { +impl From<EphemeralAta> for AccountSharedData { + fn from(val: EphemeralAta) -> Self { let token_account = SplAccount { - mint: self.mint, - owner: self.owner, - amount: self.amount, + mint: val.mint, + owner: val.owner, + amount: val.amount, delegate: COption::None, state: AccountState::Initialized, is_native: COption::None, delegated_amount: 0, close_authority: COption::None, }; // ... rest unchanged } }
3458-3460: Fix confusing double-negation logic.Line 3458:
if !record.owner.ne(&EATA_PROGRAM_ID)is equivalent toif record.owner == EATA_PROGRAM_ID, which seems backwards. The delegation record'sownerfield typically stores the original account owner (wallet), not a program ID. Clarify the intended logic.If you're checking that the record owner is NOT the eATA program:
- if !record.owner.ne(&EATA_PROGRAM_ID) { + if record.owner == EATA_PROGRAM_ID { return None; }Or if you meant to validate something else, please clarify with a comment explaining what
record.ownerrepresents in this context.
3462-3467: Critical: Buffer length check is insufficient.Line 3462 checks
data.len() < 40, but line 3467 readsdata[64..72]for the amount. If data length is between 40 and 71 bytes, this will panic with an index out of bounds error.- if data.len() < 40 { + if data.len() < 72 { return None; }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
Cargo.toml(1 hunks)magicblock-chainlink/src/chainlink/fetch_cloner.rs(10 hunks)magicblock-chainlink/src/testing/eatas.rs(1 hunks)magicblock-core/src/lib.rs(1 hunks)magicblock-core/src/token_programs.rs(1 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit.rs(3 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs(2 hunks)
🧰 Additional context used
🧠 Learnings (15)
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.
Applied to files:
magicblock-core/src/lib.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-core/src/token_programs.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/testing/eatas.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-25T11:07:20.001Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/programs/flexi-counter/src/processor.rs:643-680
Timestamp: 2025-11-25T11:07:20.001Z
Learning: In the compressed delegation architecture, ownership reassignment during undelegation is handled by the delegation program itself, not by the owner program's external undelegate handler. The external undelegate handler (e.g., `process_external_undelegate_compressed` in flexi-counter) is a callback for program-specific cleanup (restoring lamports and data) after the delegation program has already reassigned ownership back to the original owner stored in the CompressedDelegationRecord.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Applied to files:
Cargo.toml
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.
Applied to files:
Cargo.toml
📚 Learning: 2025-11-19T11:31:24.218Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-chainlink/tests/ix_01_ensure-accounts.rs:85-114
Timestamp: 2025-11-19T11:31:24.218Z
Learning: In the magicblock-validator codebase, compressed delegation records are never subscribed to by design. Tests for compressed delegation flows should focus on verifying that the delegated account (e.g., counter PDA) is cloned as delegated and not subscribed, but do not need to check for subscription to delegation-record-like PDAs in the compressed path because subscriptions to compressed delegation records never occur.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rs
🧬 Code graph analysis (5)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
magicblock-core/src/token_programs.rs (2)
derive_ata(18-24)derive_eata(38-44)
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (1)
magicblock-core/src/token_programs.rs (2)
derive_ata(18-24)derive_eata(38-44)
magicblock-chainlink/src/testing/eatas.rs (1)
magicblock-core/src/token_programs.rs (2)
derive_ata(18-24)derive_eata(38-44)
magicblock-core/src/token_programs.rs (1)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)
try_derive_eata_address_and_bump(3399-3406)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)
magicblock-core/src/token_programs.rs (1)
try_derive_eata_address_and_bump(47-55)
🔇 Additional comments (6)
magicblock-core/src/lib.rs (1)
18-18: LGTM! Token programs module properly exported.The new module declaration correctly exposes the token program utilities for use across the crate.
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (1)
455-618: ATA→eATA remapping tests look solid.Both test cases correctly:
- Create delegated SPL ATA accounts with proper layout
- Execute the full schedule→accept flow
- Verify the committed pubkey remaps to the derived eATA
- Check undelegation status where applicable
The test coverage aligns well with the MIMD-0013 implementation.
magicblock-chainlink/src/testing/eatas.rs (1)
1-3: Good use of re-exports to avoid constant duplication.Re-exporting from
magicblock_core::token_programsis the right approach to avoid duplicating program ID constants across files.magicblock-core/src/token_programs.rs (1)
1-55: Well-structured token program utilities module.The implementation correctly:
- Defines program IDs using the
pubkey!macro for compile-time validation- Implements standard Solana PDA derivation patterns for ATAs and eATAs
- Provides both infallible (
find_program_address) and fallible (try_find_program_address) variants- Uses appropriate seed combinations per ATA and eATA specifications
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)
3331-3393: ATA detection logic is well-implemented.The
is_atafunction correctly:
- Validates the account owner is either spl-token or spl-token-2022
- Safely extracts mint and owner from the account data
- Derives the expected ATA address using proper seeds
- Returns
Some(AtaInfo)only when the pubkey matches the derived addressCargo.toml (1)
191-192: Bothspl-tokenv7.0 andspl-token-2022v7.0 exist and are safe to use.Version 7.0.0 of spl-token was released on 2024-11-01, and version 7.0.0 of spl-token-2022 was released on 2025-01-17. Both are stable releases. Token-2022 has undergone security audits from Halborn, Zellic, NCC, Trail of Bits, and OtterSec, and no critical security vulnerabilities were found in available documentation.
Likely an incorrect or invalid review comment.
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
♻️ Duplicate comments (2)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)
1114-1196: eATA subscription cleanup is still incomplete.The existing review comment on lines 1109-1196 remains valid. eATA accounts are subscribed to at line 1124 but are never tracked for cleanup. When:
- The eATA doesn't exist (
maybe_eata_accountisNone)- The delegation record fetch fails or returns
None- The eATA is not delegated to this validator
maybe_into_atareturnsNone...the eATA subscription remains active unnecessarily.
Consider tracking eATA pubkeys and cancelling subscriptions in the fallback paths where the eATA data is not used.
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
184-208: Consider extracting the ATA→eATA remapping to a helper function.Per previous review feedback from taco-paco, this remapping logic should also apply to
ScheduleBaseIntent/process_schedule_base_intent. Extracting to a shared helper would ensure consistency:fn remap_ata_to_eata_if_delegated( pubkey: &Pubkey, account: &impl ReadableAccount, ) -> Pubkey { if account.delegated() { if let Some(ata) = is_ata(pubkey, account) { return derive_eata(&ata.owner, &ata.mint); } } *pubkey }The current logic is correct, but consolidating it would prevent divergence between commit paths.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
magicblock-chainlink/src/chainlink/fetch_cloner.rs(10 hunks)magicblock-core/Cargo.toml(1 hunks)magicblock-core/src/token_programs.rs(1 hunks)programs/magicblock/Cargo.toml(1 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit.rs(3 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs(2 hunks)
🧰 Additional context used
🧠 Learnings (12)
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-core/Cargo.tomlprograms/magicblock/Cargo.toml
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-19T11:31:24.218Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-chainlink/tests/ix_01_ensure-accounts.rs:85-114
Timestamp: 2025-11-19T11:31:24.218Z
Learning: In the magicblock-validator codebase, compressed delegation records are never subscribed to by design. Tests for compressed delegation flows should focus on verifying that the delegated account (e.g., counter PDA) is cloned as delegated and not subscribed, but do not need to check for subscription to delegation-record-like PDAs in the compressed path because subscriptions to compressed delegation records never occur.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-25T11:07:20.001Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/programs/flexi-counter/src/processor.rs:643-680
Timestamp: 2025-11-25T11:07:20.001Z
Learning: In the compressed delegation architecture, ownership reassignment during undelegation is handled by the delegation program itself, not by the owner program's external undelegate handler. The external undelegate handler (e.g., `process_external_undelegate_compressed` in flexi-counter) is a callback for program-specific cleanup (restoring lamports and data) after the delegation program has already reassigned ownership back to the original owner stored in the CompressedDelegationRecord.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rs
🧬 Code graph analysis (3)
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2)
magicblock-chainlink/src/testing/eatas.rs (1)
create_ata_account(10-33)magicblock-core/src/token_programs.rs (2)
derive_ata(21-27)derive_eata(41-47)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
magicblock-core/src/token_programs.rs (2)
derive_eata(41-47)is_ata(72-120)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)
magicblock-core/src/token_programs.rs (2)
is_ata(72-120)try_derive_eata_address_and_bump(50-58)
🔇 Additional comments (16)
programs/magicblock/Cargo.toml (1)
27-27: LGTM!Adding
magicblock-chainlinkas a dev-dependency with thedev-contextfeature is appropriate for enabling test utilities related to the new ATA/eATA functionality.magicblock-core/Cargo.toml (1)
25-26: LGTM!Adding
spl-tokenandspl-token-2022workspace dependencies is necessary for the new token programs module to support both legacy and Token-2022 program owners.magicblock-core/src/token_programs.rs (4)
9-18: LGTM! Program ID constants are well-defined.The SPL Token, Associated Token, and eATA program IDs are clearly documented and use the canonical addresses.
21-58: LGTM! PDA derivation functions are correctly implemented.The ATA derivation follows the standard SPL Associated Token Account seeds
[owner, token_program, mint], and the eATA derivation uses the simpler[owner, mint]seeds. Bothtry_*variants properly expose the bump seed for callers that need it.
72-120: LGTM! ATA detection logic is robust.The
is_atafunction correctly:
- Validates ownership by SPL Token or Token-2022 programs
- Safely parses mint and owner from account data with proper length checks
- Uses the correct PDA derivation seeds including the actual token program owner
- Returns structured
AtaInfofor downstream use
176-200: LGTM! eATA to ATA projection logic is well-implemented.The
MaybeIntoAtaimplementation:
- Correctly guards conversion to only proceed when
owner_programmatchesEATA_PROGRAM_ID- Uses safe parsing with proper buffer length validation (72 bytes minimum)
- Cleanly constructs the
EphemeralAtaand converts toAccountSharedDatamagicblock-chainlink/src/chainlink/fetch_cloner.rs (4)
14-17: LGTM! Imports for ATA/eATA utilities are properly added.The imports from
magicblock_core::token_programsprovide the necessary helpers for ATA detection, eATA derivation, and conversion.
718-724: LGTM! ATA detection is correctly integrated into the account classification flow.ATAs are properly detected after executable/native loader checks and before falling back to plain accounts, ensuring they receive special eATA handling.
1165-1178: LGTM! Delegation check and ATA projection logic are correct.The logic correctly:
- Validates that the delegation authority is this validator (or confined/default)
- Passes
deleg.owner(the original account owner from the delegation record) tomaybe_into_ata- Only projects eATA data to ATA form when the delegation record indicates eATA ownership
- Sets the delegated flag on the resulting account
3332-3333: LGTM!The comment helpfully documents that local helpers were refactored to
magicblock_core::token_programs.programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
3-3: LGTM!Import of
derive_eatafrom the centralized token programs module is correct.
188-202: Verify: All delegated ATAs are remapped to eATAs unconditionally.The logic remaps every delegated ATA to its corresponding eATA address for commit/undelegate operations. This assumes:
- All delegated ATAs should commit through the eATA program
- The eATA address exists on-chain (or the commit will handle creation)
If there are scenarios where ATAs are delegated directly (not through eATA flow), this remapping could cause issues. Please confirm this behavior aligns with MIMD 0013 requirements.
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (4)
258-266: LGTM!The imports cleanly leverage the shared testing utilities (
create_ata_account) and token program helpers (derive_ata,derive_eata) for the new remapping tests.
268-277: LGTM!Clean refactoring that reuses the shared
create_ata_accounthelper. The conversion toAccountSharedDataand delegation flag setting are straightforward.
522-529: LGTM!The assertion correctly verifies that the committed pubkey is remapped from the original ATA to the derived eATA, validating the core MIMD-0013 remapping behavior.
604-613: LGTM!Assertions correctly verify both the ATA→eATA remapping and that the undelegation flag is set, comprehensively covering the commit-and-undelegate flow.
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
Show resolved
Hide resolved
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
magicblock-chainlink/src/testing/eatas.rs(1 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs(2 hunks)
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:29.027Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-12-17T12:46:29.027Z
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:29.027Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-chainlink/src/testing/eatas.rs
🧬 Code graph analysis (2)
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2)
magicblock-chainlink/src/testing/eatas.rs (1)
create_ata_account(11-34)magicblock-core/src/token_programs.rs (2)
derive_ata(21-27)derive_eata(41-47)
magicblock-chainlink/src/testing/eatas.rs (1)
magicblock-core/src/token_programs.rs (2)
derive_ata(21-27)derive_eata(41-47)
🔇 Additional comments (5)
magicblock-chainlink/src/testing/eatas.rs (2)
1-9: LGTM! Clean consolidation of shared token program utilities.Re-exporting from
magicblock_core::token_programsproperly addresses the previous duplication concerns and centralizes the ATA/eATA derivation logic.
11-34: LGTM! Correct SPL token account construction.The function properly uses
SplAccount::packto serialize a valid SPL token account structure and correctly sets the owner toSPL_TOKEN_PROGRAM_ID.programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (3)
258-277: LGTM! Clean helper reusing shared utilities.The helper
make_delegated_spl_ata_accountproperly leverages the sharedcreate_ata_accounthelper frommagicblock_chainlink::testing::eatas, avoiding duplication and ensuring consistent account structure.
450-529: LGTM! Solid test for ATA→eATA remapping.The test correctly:
- Derives both ATA and expected eATA addresses from the same wallet/mint
- Constructs a delegated SPL-ATA account at the ATA address
- Schedules and accepts a commit
- Verifies the committed pubkey is the derived eATA
This properly validates the MIMD-0013 remapping behavior.
531-613: LGTM! Comprehensive undelegation + remapping test.The test extends the remapping verification to include the undelegation flow, correctly asserting both:
- The pubkey remaps to eATA
is_undelegate()returnstrueGood coverage of the combined behavior.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
410-424: Consider adding logging for remapping events.The remapping logic is correct and consistent across both
StandaloneandWithBaseActionsbranches. However, unlikeprocess_schedule_commit.rs(lines 192-197), there's no logging when remapping occurs here. Sincecontext.invoke_contextis available, consider adding similar logging for debugging consistency:if remapped != pubkey { ic_msg!( context.invoke_context, "CommitType: remapping ATA {} -> eATA {} for commit", pubkey, remapped ); }This would improve observability across both commit paths.
Also applies to: 444-458
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
magicblock-chainlink/src/testing/eatas.rs(1 hunks)programs/magicblock/src/magic_scheduled_base_intent.rs(3 hunks)programs/magicblock/src/schedule_transactions/mod.rs(1 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit.rs(2 hunks)
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:29.027Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
programs/magicblock/src/magic_scheduled_base_intent.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
programs/magicblock/src/magic_scheduled_base_intent.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-chainlink/src/testing/eatas.rsprograms/magicblock/src/schedule_transactions/mod.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.
Applied to files:
programs/magicblock/src/magic_scheduled_base_intent.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
programs/magicblock/src/magic_scheduled_base_intent.rs
📚 Learning: 2025-12-17T12:46:29.027Z
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:29.027Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
Applied to files:
programs/magicblock/src/magic_scheduled_base_intent.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-chainlink/src/testing/eatas.rsprograms/magicblock/src/schedule_transactions/mod.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
programs/magicblock/src/magic_scheduled_base_intent.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
magicblock-chainlink/src/testing/eatas.rs
🧬 Code graph analysis (4)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
programs/magicblock/src/schedule_transactions/mod.rs (1)
remap_ata_to_eata_if_delegated(52-75)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
programs/magicblock/src/schedule_transactions/mod.rs (1)
remap_ata_to_eata_if_delegated(52-75)magicblock-committor-service/src/tasks/task_builder.rs (1)
committed_accounts(142-145)
magicblock-chainlink/src/testing/eatas.rs (1)
magicblock-core/src/token_programs.rs (2)
derive_ata(21-27)derive_eata(41-47)
programs/magicblock/src/schedule_transactions/mod.rs (2)
magicblock-core/src/token_programs.rs (2)
derive_ata(21-27)derive_eata(41-47)magicblock-magic-program-api/src/args.rs (1)
data(26-28)
🔇 Additional comments (7)
magicblock-chainlink/src/testing/eatas.rs (1)
1-9: LGTM - Clean re-exports and imports.The re-exports from
magicblock_core::token_programsand standard imports are well-organized. The previous duplication concerns have been properly addressed by using shared definitions from the core module.programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (3)
39-39: LGTM!The documentation comment usefully points developers to the centralized location for token program utilities.
183-198: LGTM! Past feedback addressed.The remapping logic correctly uses the extracted helper function
remap_ata_to_eata_if_delegatedand logs remapping events for debugging. This addresses taco-paco's suggestion to extract the logic into a reusable helper function.Based on learnings from taco-paco's review feedback.
202-202: Correct usage of remapped pubkey.The
target_pubkey(potentially remapped to eATA) is correctly used when constructing theCommittedAccount, ensuring that delegated ATAs are committed to their corresponding eATAs.programs/magicblock/src/magic_scheduled_base_intent.rs (1)
22-22: LGTM!The import of
remap_ata_to_eata_if_delegatedis correct and enables ATA→eATA remapping in the args-based commit path.programs/magicblock/src/schedule_transactions/mod.rs (2)
42-50: LGTM!The comment clearly documents the helper's purpose, and the necessary imports are correctly included.
52-75: LGTM! Correct and defensive implementation.The function correctly implements ATA→eATA remapping with appropriate guards:
- Validates delegation and SPL Token ownership
- Correctly parses mint (bytes 0-32) and owner (bytes 32-64) per SPL Token account layout
- Derives and validates ATA before remapping to eATA
- Falls back safely to the original pubkey on any validation failure
The ATA derivation check (
ata == *pubkey) provides implicit validation that the account structure is as expected, making the implementation robust against edge cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
magicblock-api/src/domain_registry_manager.rs (1)
1-11: Consider extracting the program ID conversion.The pattern
ID.to_bytes().into()appears multiple times (lines 107, 175). Consider defining a constant or helper to reduce repetition:use mdp::ID; // Near imports or as a lazy_static/const fn mdp_program_id() -> Pubkey { ID.to_bytes().into() }This is a minor suggestion for improved readability.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (16)
Cargo.toml(1 hunks)magicblock-api/src/domain_registry_manager.rs(6 hunks)magicblock-api/src/magic_validator.rs(1 hunks)magicblock-chainlink/Cargo.toml(1 hunks)magicblock-chainlink/src/chainlink/fetch_cloner.rs(8 hunks)magicblock-chainlink/src/testing/eatas.rs(1 hunks)magicblock-chainlink/src/testing/mod.rs(1 hunks)magicblock-committor-service/src/intent_execution_manager/db.rs(1 hunks)magicblock-processor/src/lib.rs(1 hunks)magicblock-processor/src/scheduler/coordinator.rs(3 hunks)programs/magicblock/Cargo.toml(1 hunks)programs/magicblock/src/magic_scheduled_base_intent.rs(3 hunks)programs/magicblock/src/schedule_transactions/mod.rs(2 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit.rs(2 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs(2 hunks)test-integration/Cargo.toml(1 hunks)
🧰 Additional context used
🧠 Learnings (21)
📓 Common learnings
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:29.027Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
programs/magicblock/src/magic_scheduled_base_intent.rsmagicblock-processor/src/lib.rsmagicblock-api/src/magic_validator.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
programs/magicblock/src/magic_scheduled_base_intent.rsmagicblock-processor/src/lib.rsmagicblock-api/src/magic_validator.rsmagicblock-api/src/domain_registry_manager.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-processor/src/scheduler/coordinator.rsprograms/magicblock/src/schedule_transactions/mod.rsmagicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.
Applied to files:
programs/magicblock/src/magic_scheduled_base_intent.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
programs/magicblock/src/magic_scheduled_base_intent.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-processor/src/scheduler/coordinator.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
magicblock-processor/src/lib.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rsmagicblock-processor/src/scheduler/coordinator.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
magicblock-processor/src/lib.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Applied to files:
magicblock-api/src/magic_validator.rsprograms/magicblock/Cargo.tomltest-integration/Cargo.tomlCargo.tomlmagicblock-chainlink/Cargo.toml
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-17T12:46:29.027Z
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:29.027Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rsprograms/magicblock/src/schedule_transactions/mod.rsmagicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-19T11:31:24.218Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-chainlink/tests/ix_01_ensure-accounts.rs:85-114
Timestamp: 2025-11-19T11:31:24.218Z
Learning: In the magicblock-validator codebase, compressed delegation records are never subscribed to by design. Tests for compressed delegation flows should focus on verifying that the delegated account (e.g., counter PDA) is cloned as delegated and not subscribed, but do not need to check for subscription to delegation-record-like PDAs in the compressed path because subscriptions to compressed delegation records never occur.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-25T11:07:20.001Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/programs/flexi-counter/src/processor.rs:643-680
Timestamp: 2025-11-25T11:07:20.001Z
Learning: In the compressed delegation architecture, ownership reassignment during undelegation is handled by the delegation program itself, not by the owner program's external undelegate handler. The external undelegate handler (e.g., `process_external_undelegate_compressed` in flexi-counter) is a callback for program-specific cleanup (restoring lamports and data) after the delegation program has already reassigned ownership back to the original owner stored in the CompressedDelegationRecord.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-10-26T16:53:29.820Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: magicblock-chainlink/src/remote_account_provider/mod.rs:134-0
Timestamp: 2025-10-26T16:53:29.820Z
Learning: In magicblock-chainlink/src/remote_account_provider/mod.rs, the `Endpoint::separate_pubsub_url_and_api_key()` method uses `split_once("?api-key=")` because the api-key parameter is always the only query parameter right after `?`. No additional query parameter parsing is needed for this use case.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-13T09:38:43.804Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/locks.rs:64-102
Timestamp: 2025-11-13T09:38:43.804Z
Learning: In magicblock-processor's TransactionScheduler (scheduler/mod.rs line 59), the executor count is clamped to MAX_SVM_EXECUTORS (63) at initialization time, and executor IDs are assigned sequentially from 0 to count-1. This architectural guarantee ensures that executor IDs used in the bitmask-based AccountLock (scheduler/locks.rs) will always be within valid bounds for bit shifting operations, making runtime bounds checks unnecessary.
Applied to files:
magicblock-processor/src/scheduler/coordinator.rs
📚 Learning: 2025-11-04T10:53:50.922Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/locks.rs:110-122
Timestamp: 2025-11-04T10:53:50.922Z
Learning: In magicblock-processor, the TransactionScheduler runs in a single, dedicated thread and will always remain single-threaded. The `next_transaction_id()` function in scheduler/locks.rs uses `unsafe static mut` which is safe given this architectural guarantee.
Applied to files:
magicblock-processor/src/scheduler/coordinator.rs
📚 Learning: 2025-10-21T10:34:59.140Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-accounts-db/src/lib.rs:63-72
Timestamp: 2025-10-21T10:34:59.140Z
Learning: In magicblock-validator, the AccountsDb "stop-the-world" synchronizer is managed at the processor/executor level, not at the AccountsDb API level. Transaction executors in magicblock-processor hold a read lock (sync.read()) for the duration of each slot and release it only at slot boundaries, ensuring all account writes happen under the read lock. Snapshot operations acquire a write lock, blocking until all executors release their read locks. This pattern ensures mutual exclusion between writes and snapshots without requiring read guards in AccountsDb write APIs.
Applied to files:
magicblock-processor/src/scheduler/coordinator.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-chainlink/src/testing/mod.rsmagicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-11-07T18:19:48.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: test-integration/programs/schedulecommit/Cargo.toml:19-20
Timestamp: 2025-11-07T18:19:48.996Z
Learning: In Solana programs (crates depending on solana-program), the empty feature flags `custom-heap = []` and `custom-panic = []` are standard declarations required to avoid compiler warnings. These should not be flagged as unused features in Cargo.toml files for Solana program crates.
Applied to files:
programs/magicblock/Cargo.toml
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.
Applied to files:
Cargo.toml
🧬 Code graph analysis (5)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
programs/magicblock/src/schedule_transactions/mod.rs (1)
remap_ata_to_eata_if_delegated(50-73)
magicblock-api/src/magic_validator.rs (1)
test-integration/test-magicblock-api/tests/test_claim_fees.rs (1)
validator_keypair(23-29)
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2)
magicblock-chainlink/src/testing/eatas.rs (1)
create_ata_account(11-34)magicblock-core/src/token_programs.rs (2)
derive_ata(21-27)derive_eata(41-47)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)
magicblock-core/src/token_programs.rs (2)
is_ata(72-120)try_derive_eata_address_and_bump(50-58)
magicblock-chainlink/src/testing/eatas.rs (1)
magicblock-core/src/token_programs.rs (2)
derive_ata(21-27)derive_eata(41-47)
🔇 Additional comments (32)
magicblock-processor/src/scheduler/coordinator.rs (1)
154-154: LGTM! Clean refactoring of iterator usage.The refactoring correctly moves
.enumerate()from the iterator creation to the specific usage sites where indices are needed. This approach is more flexible and makes the final loop (lines 217-218) cleaner since it doesn't need to destructure and ignore the index. The change from passingaccby value to&accby reference at line 218 is more idiomatic given thatclear_account_contentionexpects&Pubkey.Also applies to: 157-157, 202-202, 217-219
magicblock-api/src/magic_validator.rs (1)
528-536: LGTM!The conversion of
validator_keypair.pubkey()to bytes aligns with the updatedRecordV0structure that now stores the identity as a byte sequence, consistent with the byte-oriented handling introduced across the codebase for MIMD 0013.magicblock-api/src/domain_registry_manager.rs (6)
60-74: LGTM!The conversion
pda.to_bytes().into()is correctly applied sincevalidator_info.pda()returns a type from themdpcrate that requires explicit conversion tosolana_pubkey::Pubkeyforsend_instruction.
92-103: LGTM!Consistent conversion pattern as in
register().
105-108: LGTM!The conversion of
ID.to_bytes().into()is necessary becausemdp::IDrequires explicit conversion tosolana_pubkey::Pubkeyforfind_program_address. The temporary lifetime is correctly extended by the reference.
110-127: LGTM!The conversion logic is correct:
pdacomes fromSelf::get_pda()which already returnssolana_pubkey::Pubkey, so no conversion is needed forsend_instructionpayer.pubkey().to_bytes().into()is required becauseUnregisterinstruction expects a bytes-based identity type
129-151: LGTM!The conversion
validator_info.pda().0.to_bytes().into()correctly transforms themdpcrate's PDA type tosolana_pubkey::Pubkeyfor thefetch_validator_infocall.
174-178: LGTM!The conversion
ID.to_bytes().into()correctly transformsmdp::IDtosolana_pubkey::Pubkeyfor theInstruction::new_with_borshprogram ID parameter.magicblock-processor/src/lib.rs (2)
20-28: LGTM: Feature flag activation is correct.The activation of
disable_rent_fees_collectionon line 23 correctly justifies the removal of the rent collector instance. The feature flags are well-documented and appropriately activated for ephemeral rollup operations.
45-54: The change to setrent_collectortoNoneis correct and safe. The codebase uses idiomatic Rust Option handling (.as_ref().map().and_then()) that gracefully handles theNonecase without unsafe unwraps or panics. This approach is consistent with thedisable_rent_fees_collectionfeature flag logic.magicblock-chainlink/Cargo.toml (1)
40-41: LGTM!The workspace dependencies for
spl-tokenandspl-token-2022are correctly added to support the new ATA/eATA handling logic in the chainlink module.magicblock-committor-service/src/intent_execution_manager/db.rs (1)
54-63: LGTM!The simplification removing the explicit
.into_iter()is idiomatic—VecDeque::extendaccepts anyIntoIterator, andVec<T>satisfies that directly.programs/magicblock/Cargo.toml (1)
44-44: LGTM!The dev-dependency on
magicblock-chainlinkwithdev-contextfeature is correctly scoped to enable the testing utilities (create_ata_account, etc.) used by the new ATA/eATA remapping tests.programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (3)
255-275: LGTM!The helper
make_delegated_spl_ata_accountcorrectly reuses the sharedcreate_ata_accountutility, avoiding code duplication while properly setting the delegated flag for test scenarios.
448-527: LGTM!The test correctly validates the ATA→eATA remapping flow: it sets up a delegated SPL Token ATA, schedules a commit, and verifies the committed pubkey is remapped to the corresponding eATA derived from the same wallet owner and mint.
529-611: LGTM!The test correctly validates the combined ATA→eATA remapping and undelegation flow, asserting both the pubkey remapping and the
is_undelegate()flag.test-integration/Cargo.toml (1)
92-92: Exact version pinning confirmed as intentional; spl-token 7.0.0 is stable and published.The exact version pin
=7.0(spl-token 7.0.0, published Nov 2024) locks the dependency for reproducible builds. Note that version 9.0.0 is available on crates.io; ensure this older version is intentional for workspace compatibility rather than oversight.Cargo.toml (1)
204-206: LGTM! Clean workspace dependency additions.The SPL Token dependencies are properly declared at the workspace level with consistent versioning (7.0 for both crates).
magicblock-chainlink/src/testing/mod.rs (1)
10-11: LGTM! Test utilities properly exposed.The new
eatasmodule is correctly feature-gated for test/dev contexts, consistent with other testing modules.programs/magicblock/src/magic_scheduled_base_intent.rs (3)
21-21: LGTM! Remapping helper properly imported.The
remap_ata_to_eata_if_delegatedimport enables consistent ATA-to-eATA remapping across schedule paths.
410-422: LGTM! Consistent ATA remapping applied in Standalone path.The remapping logic correctly:
- Derives the target pubkey (ATA or eATA) based on delegation status
- Uses the remapped key for the CommittedAccount
- Applies owner normalization after remapping
This matches the design in
process_schedule_commit.rs.
444-457: LGTM! Consistent ATA remapping applied in WithBaseActions path.The remapping logic is identical to the Standalone path, ensuring consistent behavior across both commit types.
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
36-36: Good documentation of centralized token program constants.The comment clarifies that program IDs and derivation helpers are centralized in
magicblock-core::token_programs, improving maintainability.
180-199: LGTM! ATA-to-eATA remapping correctly implemented.The remapping logic:
- Calls
remap_ata_to_eata_if_delegatedto compute the target pubkey- Logs the remapping when it occurs (useful for debugging)
- Uses the remapped pubkey for the committed account
This aligns with the schedule_transactions module design and ensures delegated ATAs are committed as eATAs.
programs/magicblock/src/schedule_transactions/mod.rs (2)
44-48: LGTM! Token program utilities properly imported.The imports bring in the necessary helpers from
magicblock-core::token_programsfor ATA/eATA derivation.
50-73: SPL Token account data layout is correct, but function only supports legacy spl-token.The byte layout assumption is verified and correct (bytes 0-32 contain mint pubkey, bytes 32-64 contain owner pubkey). This layout is consistent with how the codebase parses SPL Token accounts elsewhere and is validated by the test suite.
However,
remap_ata_to_eata_if_delegatedonly checksaccount.owner() == &SPL_TOKEN_PROGRAM_IDand does not supportspl-token-2022. The parallelis_atafunction in the same codebase handles both token programs. If spl-token-2022 support is needed, add a check forspl_token_2022::id()similar to theis_atafunction (magicblock-core/src/token_programs.rs:78-80).magicblock-chainlink/src/testing/eatas.rs (2)
1-9: LGTM! Clean imports and re-exports.The module properly imports necessary types and re-exports token program utilities for test use.
11-34: LGTM! Standard SPL token account creation.The function correctly:
- Initializes a standard SPL Token account structure
- Uses
Packtrait for proper serialization- Calculates lamports based on account size
- Sets appropriate owner (SPL_TOKEN_PROGRAM_ID)
This is a solid test helper for creating ATA accounts.
magicblock-chainlink/src/chainlink/fetch_cloner.rs (4)
14-17: LGTM! Token program utilities properly imported.The new imports enable ATA detection, eATA derivation, and eATA-to-ATA conversion functionality.
670-740: LGTM! ATA detection and collection correctly integrated.The fold accumulator is properly extended to:
- Add
atasto the tuple (lines 670, 672, 678, 739)- Detect ATAs using
is_ata(line 718)- Collect ATA accounts with their metadata (lines 719-724)
This maintains the existing flow while adding ATA-specific handling.
760-766: LGTM! Logging updated to include ATA accounts.The debug logging now includes the
atascollection, providing visibility into ATA handling during fetch operations.
1109-1196: Verify eATA subscription lifecycle and conversion safety.The ATA/eATA handling implements a sophisticated flow:
Subscription management (lines 1118-1138): Subscribes to both ATA and eATA. Per learnings, eATA subscriptions are intentionally NOT cancelled even when conversion fails, to watch for future creation/delegation.
Conversion logic (lines 1154-1179):
- Fetches delegation record for the eATA
- Checks if delegated to validator (including default/confined case)
- Converts eATA to ATA-like structure using
maybe_into_ata- Marks as delegated and captures commit frequency
Fallback behavior (lines 1151-1153, 1188-1193): On errors, logs warnings but continues processing other accounts.
Potential concerns:
- The eATA subscriptions accumulate (never cancelled). Verify this doesn't cause memory/subscription limit issues at scale.
- When
maybe_into_atareturnsNone, the originalata_accountis used (line 1183). Ensure this is the intended fallback.Based on learnings, this behavior is intentional. However, please verify:
#!/bin/bash # Description: Verify subscription management and conversion behavior # Check if there are subscription limits or cleanup mechanisms rg -n "max.*subscription|subscription.*limit|cleanup.*subscription" --type rust -C3 # Verify MaybeIntoAta trait and its None return cases ast-grep --pattern $'impl MaybeIntoAta for $_ { $$$ fn maybe_into_ata($$$) -> Option<$_> { $$$ } $$$ }' # Check if ata_account is intended as fallback when eATA conversion fails rg -n "account_to_clone.*ata_account|ata.*fallback" --type rust -C5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
Cargo.toml(3 hunks)magicblock-chainlink/src/chainlink/fetch_cloner.rs(8 hunks)magicblock-core/src/token_programs.rs(1 hunks)test-integration/Cargo.toml(3 hunks)test-integration/Makefile(1 hunks)test-integration/test-chainlink/src/ixtest_context.rs(1 hunks)test-integration/test-chainlink/tests/ix_ata_eata_replace.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (15)
📓 Common learnings
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:36.207Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
📚 Learning: 2025-12-17T12:46:36.207Z
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:36.207Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
Applied to files:
test-integration/test-chainlink/tests/ix_ata_eata_replace.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rsmagicblock-core/src/token_programs.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
test-integration/test-chainlink/tests/ix_ata_eata_replace.rstest-integration/test-chainlink/src/ixtest_context.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
test-integration/test-chainlink/tests/ix_ata_eata_replace.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rstest-integration/test-chainlink/src/ixtest_context.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
test-integration/test-chainlink/tests/ix_ata_eata_replace.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rstest-integration/test-chainlink/src/ixtest_context.rsCargo.toml
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
test-integration/test-chainlink/tests/ix_ata_eata_replace.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rstest-integration/test-chainlink/src/ixtest_context.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.
Applied to files:
test-integration/test-chainlink/tests/ix_ata_eata_replace.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rstest-integration/test-chainlink/src/ixtest_context.rs
📚 Learning: 2025-11-19T11:31:24.218Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-chainlink/tests/ix_01_ensure-accounts.rs:85-114
Timestamp: 2025-11-19T11:31:24.218Z
Learning: In the magicblock-validator codebase, compressed delegation records are never subscribed to by design. Tests for compressed delegation flows should focus on verifying that the delegated account (e.g., counter PDA) is cloned as delegated and not subscribed, but do not need to check for subscription to delegation-record-like PDAs in the compressed path because subscriptions to compressed delegation records never occur.
Applied to files:
test-integration/test-chainlink/tests/ix_ata_eata_replace.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rstest-integration/test-chainlink/src/ixtest_context.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rstest-integration/test-chainlink/src/ixtest_context.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rstest-integration/test-chainlink/src/ixtest_context.rsmagicblock-core/src/token_programs.rs
📚 Learning: 2025-11-25T11:07:20.001Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/programs/flexi-counter/src/processor.rs:643-680
Timestamp: 2025-11-25T11:07:20.001Z
Learning: In the compressed delegation architecture, ownership reassignment during undelegation is handled by the delegation program itself, not by the owner program's external undelegate handler. The external undelegate handler (e.g., `process_external_undelegate_compressed` in flexi-counter) is a callback for program-specific cleanup (restoring lamports and data) after the delegation program has already reassigned ownership back to the original owner stored in the CompressedDelegationRecord.
Applied to files:
magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Applied to files:
Cargo.tomltest-integration/Cargo.toml
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.
Applied to files:
Cargo.tomltest-integration/Cargo.toml
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.
Applied to files:
Cargo.toml
🧬 Code graph analysis (1)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)
magicblock-core/src/token_programs.rs (2)
is_ata(72-120)try_derive_eata_address_and_bump(50-58)
🔇 Additional comments (13)
test-integration/Makefile (1)
219-219: LGTM! Good refactoring for maintainability.Extracting the clippy command into a reusable
linttarget and havingci-lintdepend on it follows the DRY principle and ensures consistency between local and CI linting workflows.test-integration/test-chainlink/src/ixtest_context.rs (1)
97-98: LGTM!The simplified constructor call correctly passes the
Pubkeyreference directly toAccountSharedData::new, removing the unnecessary byte conversion.test-integration/Cargo.toml (1)
39-62: Dependency updates look appropriate.The version pinning and feature flags are consistent with workspace-level changes. Using
default-features = falsewith explicit feature selection is good practice for controlling the dependency footprint.Also applies to: 92-92
Cargo.toml (1)
204-206: Workspace SPL token dependencies added correctly.The addition of
spl-tokenandspl-token-2022as workspace dependencies enables consistent version usage across the codebase for the new ATA/eATA handling functionality.test-integration/test-chainlink/tests/ix_ata_eata_replace.rs (2)
1-76: Well-structured test coverage for ATA/eATA replacement behavior.The test correctly:
- Derives ATA and eATA addresses using the helper functions
- Sets up delegation records targeting the test validator
- Verifies all relevant token account fields after
ensure_accounts- Confirms the
delegated()flag is set appropriatelyGood coverage of the happy path for delegated ATA replacement.
78-109: Good negative test case.Correctly verifies that without a delegation record, the original ATA data is preserved and the account is not marked as delegated.
magicblock-chainlink/src/chainlink/fetch_cloner.rs (4)
1114-1139: Well-structured parallel ATA/eATA fetch implementation.The implementation correctly:
- Subscribes to both ATA and derived eATA before fetching (ensuring updates are captured)
- Uses JoinSet for efficient parallel processing
- Computes effective_slot consistently with other fetch paths
- Per learnings, intentionally keeps eATA subscriptions active for future creation/delegation detection
1186-1191: Error handling uses warn-level logging rather than aborting.Unlike delegation record resolution failures which abort the entire operation, ATA/eATA resolution failures only log warnings and skip the account. This asymmetric behavior may be intentional for resilience (ATAs are supplementary to the main account flow), but worth confirming this is the desired behavior.
670-741: ATA detection integrated cleanly into the account categorization fold.The addition of the
atasaccumulator follows the existing pattern for other account types (not_found, plain, owned_by_deleg, programs). Theis_ata()check is placed after executable detection, ensuring programs aren't misclassified.
14-17: Token program imports added appropriately.The imports from
magicblock_core::token_programsprovide the necessary utilities for ATA detection and eATA derivation.magicblock-core/src/token_programs.rs (3)
1-18: LGTM: Clean module structure and well-documented constants.The imports are appropriate for the token program helpers, and the program ID constants are clearly documented with descriptive comments.
60-120: LGTM: Robust ATA validation logic.The
is_atafunction properly validates Associated Token Accounts by:
- Supporting both SPL Token and Token-2022 programs (lines 78-79)
- Parsing account data with safe error handling (lines 88-100)
- Verifying the PDA derivation matches the actual account address (lines 103-119)
This defense-in-depth approach ensures the account is a legitimate ATA rather than just trusting the data layout.
176-200: LGTM: Safe eATA to ATA conversion with proper validation.The
MaybeIntoAtaimplementation correctly:
- Guards on the
EATA_PROGRAM_IDowner (line 181)- Validates minimum data length (line 187)
- Uses safe byte parsing with
try_into().ok()?pattern (lines 190-192)- Returns
Noneon any parsing failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (6)
magicblock-chainlink/src/testing/eatas.rs(1 hunks)magicblock-core/src/token_programs.rs(1 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs(2 hunks)test-integration/Makefile(1 hunks)test-integration/test-ledger-restore/tests/14_restore_with_new_keypair.rs(1 hunks)test-integration/test-tools/src/integration_test_context.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (13)
📓 Common learnings
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:36.207Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
test-integration/test-ledger-restore/tests/14_restore_with_new_keypair.rstest-integration/test-tools/src/integration_test_context.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-core/src/token_programs.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
test-integration/test-ledger-restore/tests/14_restore_with_new_keypair.rstest-integration/test-tools/src/integration_test_context.rsmagicblock-chainlink/src/testing/eatas.rsmagicblock-core/src/token_programs.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
test-integration/test-ledger-restore/tests/14_restore_with_new_keypair.rsmagicblock-chainlink/src/testing/eatas.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-core/src/token_programs.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
test-integration/test-ledger-restore/tests/14_restore_with_new_keypair.rstest-integration/test-tools/src/integration_test_context.rsmagicblock-chainlink/src/testing/eatas.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-core/src/token_programs.rs
📚 Learning: 2025-12-17T12:46:36.207Z
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:36.207Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
Applied to files:
magicblock-chainlink/src/testing/eatas.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-core/src/token_programs.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-chainlink/src/testing/eatas.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-core/src/token_programs.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-core/src/token_programs.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rsmagicblock-core/src/token_programs.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-core/src/token_programs.rs
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.
Applied to files:
magicblock-core/src/token_programs.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.
Applied to files:
magicblock-core/src/token_programs.rs
🧬 Code graph analysis (2)
magicblock-chainlink/src/testing/eatas.rs (1)
magicblock-core/src/token_programs.rs (2)
derive_ata(28-34)derive_eata(62-68)
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2)
magicblock-chainlink/src/testing/eatas.rs (1)
create_ata_account(16-39)magicblock-core/src/token_programs.rs (2)
derive_ata(28-34)derive_eata(62-68)
🪛 checkmake (0.2.2)
test-integration/Makefile
[warning] 221-221: Missing required phony target "all"
(minphony)
[warning] 221-221: Missing required phony target "clean"
(minphony)
[warning] 221-221: Missing required phony target "test"
(minphony)
🔇 Additional comments (14)
test-integration/Makefile (3)
213-214: LGTM! Clean linting target implementation.The new
linttarget properly runs clippy across all targets with warnings treated as errors, which is a standard best practice for maintaining code quality.
219-219: LGTM! Good refactoring to eliminate duplication.The
ci-linttarget now cleanly delegates to thelinttarget, ensuring consistent linting behavior between CI and local development without command duplication.
221-263: Previous concern addressed -.PHONYdeclaration is now correct.The
linttarget is now properly included in the.PHONYdeclaration (line 223), which prevents Make from skipping the target if a file namedlintexists in the directory. This addresses the concern raised in the previous review.test-integration/test-ledger-restore/tests/14_restore_with_new_keypair.rs (1)
4-7: LGTM!The unused
IntegrationTestContextimport is correctly removed. The test obtains its context instance fromsetup_validator_with_local_remote()and doesn't need the type imported directly.magicblock-core/src/token_programs.rs (5)
1-18: LGTM: Clean imports and well-defined program ID constants.The imports are appropriate, and the three program ID constants use the compile-time
pubkey!macro correctly. The inline comments clearly identify each program.
20-86: LGTM: Well-documented derivation helpers with correct PDA seeds.The four public derivation functions have proper rustdoc comments and use the correct seed patterns:
- ATA:
[owner, SPL_TOKEN_PROGRAM_ID, mint]withASSOCIATED_TOKEN_PROGRAM_ID- eATA:
[owner, mint]withEATA_PROGRAM_IDThe
try_*variants appropriately returnOption<(Pubkey, u8)>for fallible derivation.
88-148: LGTM: Robust ATA detection with proper validation.The
is_atafunction correctly:
- Supports both
spl-tokenandspl-token-2022program owners- Validates minimum data length (64 bytes for mint + owner)
- Parses the SPL Token account layout (mint at 0..32, owner at 32..64)
- Derives the expected ATA address and compares it to the actual pubkey
The use of early returns with
Nonefor validation failures is appropriate.
174-202: Conversion logic is correct; note past discussions on.expect()andRent::default().The
From<EphemeralAta>implementation correctly constructs anSplAccountand packs it to bytes. Past reviews raised concerns about:
- Line 189:
.expect("pack spl token account")could panic in public API- Line 190:
Rent::default()may not reflect actual on-chain rent valuesThese concerns were discussed previously. The conversion logic itself is sound for test/ephemeral use cases.
Context from past reviews
Based on learnings, the maintainer indicated
.expect()is acceptable in tests, though this code is in a public API module. If this conversion is intended only for test/ephemeral contexts, consider adding a doc comment clarifying that constraint.
204-228: LGTM: Clean eATA→ATA projection with proper layout parsing.The
MaybeIntoAtaimplementation correctly:
- Guards against non-eATA accounts (line 209)
- Validates minimum data length of 72 bytes (owner + mint + amount)
- Safely parses the eATA layout using
try_into().ok()?- Converts to
AccountSharedDatavia theEphemeralAtatypeThis implementation enables the ATA/eATA remapping functionality tested in the schedule/commit tests.
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (3)
255-274: LGTM: Clean test helper for delegated ATA accounts.The
make_delegated_spl_ata_accounthelper correctly:
- Reuses
create_ata_accountfrom the test utilities for proper SPL Token layout- Converts to
AccountSharedData- Sets the delegated flag
This provides a clean way to construct test accounts with the correct ATA structure for remapping tests.
447-526: LGTM: Comprehensive test for ATA→eATA remapping in schedule-commit flow.The test correctly verifies that:
- A delegated SPL Token ATA account is used as a committee member
- The schedule-commit instruction accepts the ATA pubkey
- After acceptance, the committed pubkey is remapped to the corresponding eATA address
The test assertions at lines 522-525 confirm the remapping logic works as expected for the standard commit flow.
528-610: LGTM: Test coverage for ATA→eATA remapping with undelegation.This test verifies the remapping logic also works correctly for the schedule-commit-and-undelegate flow. The additional assertion at line 609 confirms the
is_undelegate()flag is properly set alongside the eATA remapping.Together with the previous test, this provides comprehensive coverage of both commit paths.
magicblock-chainlink/src/testing/eatas.rs (2)
1-9: LGTM: Clean re-exports consolidate constants and types.The public re-exports from
magicblock_core::token_programsprovide a convenient testing API while avoiding duplication. This addresses past review concerns about consolidating constants and theEphemeralAtastruct.
11-39: LGTM: Well-documented test utility for ATA account creation.The
create_ata_accountfunction correctly constructs an initialized SPL Token account with:
- Proper field initialization (zero balance, no delegation)
- Correct serialization via
SplAccount::pack- Appropriate owner (
SPL_TOKEN_PROGRAM_ID)The rustdoc comment clearly documents the purpose and parameters. Use of
.expect()andRent::default()is acceptable in test utilities.
Description
Implements MIMD 0013
Summary by CodeRabbit
New Features
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.